﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Bussiness.Config;
namespace FOSystem.Utility
{
    public class AppEnable : System.Web.Mvc.FilterAttribute, System.Web.Mvc.IActionFilter
    {

        public void OnActionExecuted(System.Web.Mvc.ActionExecutedContext filterContext)
        {
            throw new NotImplementedException();
        }
        ConfigBLL cfs;
        public void OnActionExecuting(System.Web.Mvc.ActionExecutingContext filterContext)
        {
            cfs = new ConfigBLL();
            FOModels.Config.Config cf = cfs.getConfigKey("AppEnable");
            if (cf.Cvalue != "1")
            {
                RouteValueDictionary redirectTargetDictionary = new RouteValueDictionary();
                redirectTargetDictionary.Add("action", "AppOffline");
                redirectTargetDictionary.Add("controller", "LayoutHelper");
                filterContext.Result = new RedirectToRouteResult(redirectTargetDictionary);
            }
        }
    }
}